home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 414_02 / private / _inswin.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-17  |  2.0 KB  |  95 lines

  1. #ifndef NO_MEMORY_H
  2. #include <memory.h>
  3. #endif
  4. #define    CURSES_LIBRARY    1
  5. #include <curses.h>
  6.  
  7. #ifdef    REGISTERWINDOWS
  8. #ifdef PDCDEBUG
  9. char *rcsid__inswin = "$Header: C:\CURSES\private\RCS\_inswin.c 2.1 1993/06/18 20:23:28 MH Rel MH $";
  10. #endif
  11.  
  12.  
  13.  
  14.  
  15. /*man-start*********************************************************************
  16.  
  17.   _inswin()    - Register Window with PDCurses for auto refresh
  18.  
  19.   PDCurses Description:
  20.      This is a private PDCurses routine.
  21.  
  22.      This routine inserts the passed window pointer after the specified
  23.      window.     If the specified window is a (void*)0, then the passed
  24.      window pointer is inserted first in the list.
  25.  
  26.      If the 'before' window is not on the visible list, then 'win'
  27.      will be insed to the end of the list.
  28.  
  29.      This is the beginnings of full-tiled window support.  It is _very_
  30.      raw at this point.
  31.  
  32.   PDCurses Return Value:
  33.      This function returns OK on success and ERR on error.
  34.  
  35.   PDCurses Errors:
  36.      No errors are defined for this function.
  37.  
  38.   Portability:
  39.      PDCurses    bool    _inswin( WINDOW* win, WINDOW* before );
  40.  
  41. **man-end**********************************************************************/
  42.  
  43. bool    _inswin(WINDOW *win, WINDOW *before)
  44. {
  45. extern    void*    (*mallc)( size_t );
  46. extern    void*    (*callc)( size_t, size_t );
  47. extern    void    (*fre)( void* );
  48.  
  49.     WINDS  *root = _cursvar.visible;
  50.     WINDS  *wlst = _findwin(before);
  51.     WINDS  *new  = (*mallc)(sizeof(WINDS));
  52.  
  53. #ifdef PDCDEBUG
  54.     if (trace_on) PDC_debug("PDC_inswin() - called\n");
  55. #endif
  56.  
  57.     if (new == (WINDS *)NULL)
  58.         return( FALSE );
  59.  
  60.     _rmwin(win);
  61.     memset(new, 0, sizeof(WINDS));
  62.     new->w = win;
  63.     if (wlst == (WINDS *)NULL)
  64.     {
  65.         if (root == (WINDS *)NULL)
  66.         {
  67.             _cursvar.visible = new;
  68.         }
  69.         else
  70.         {
  71.             new->next = root;
  72.             root->prev = new;
  73.             _cursvar.visible = new;
  74.         }
  75.     }
  76.     else
  77.     {
  78.         if (wlst == root)
  79.         {
  80.             new->next = root;
  81.             root->prev = new;
  82.             _cursvar.visible = new;
  83.         }
  84.         else
  85.         {
  86.             new->next = wlst;
  87.             new->prev = wlst->prev;
  88.             wlst->prev->next = new;
  89.             wlst->prev = new;
  90.         }
  91.     }
  92.     return( TRUE );
  93. }
  94. #endif
  95.